<template>
	<view class="personal">
		<view class="content">
			<view class="avatar">
				<text>头像</text>
				<!-- baseinfo -->
				<!-- <view style="flex: 1;text-align: right;" @click="tomodifyAvatar(personInfo.avatarUrl)">
					<image class="image-logo" :src="personInfo.avatarUrl" />
				</view> -->
				<view style="flex: 1;text-align: right;" @click="tomodifyAvatar(img)">
					<image class="image-logo" :src="img" />
				</view>
			</view>
			<view>
				<text>用户姓名</text>
				<!-- <view v-if="personInfo&&personInfo.account_type=='工人'" style="flex: 1;text-align: right;" @click="team_click(baseinfo.name,'用户姓名')">
					<text>{{baseinfo.name}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view v-if="personInfo&&personInfo.account_type=='班组长'" style="flex: 1;text-align: right;" @click="team_click(team_form.team_leader_name,'用户姓名')">
					<text>{{team_form.team_leader_name}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view> -->
				<view v-if="personInfo&&personInfo.account_type=='工人'" style="flex: 1;text-align: right;" @click="toauthentication">
					<text>{{baseinfo.name}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
				<view v-if="personInfo&&personInfo.account_type=='班组长'" style="flex: 1;text-align: right;" @click="toauthentication">
					<!-- <text>{{team_form.team_leader_name}}</text> -->
					<text>{{baseinfo.name}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view>
				<text>身份证号</text>
				<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" @click="toauthentication">
					<text v-if="baseinfo.idcard!=''">{{strcard}}</text>
					<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<view>
				<text>联系方式</text>
				<!-- <view style="flex: 1;text-align: right;" @click="team_click(personInfo.login,'联系方式')"> -->
				<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" class="isshow">
					<text v-if="personInfo.login!=''">{{personInfo.login}}</text>
					<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view>
			<!-- <view>
				<text>联系邮箱</text>
				<view>
					<text>{{peopleDetail.email||'暂无'}}</text>
					<u-icon name="arrow-right"></u-icon>
				</view>
			</view> -->
		</view>
		<view class="content baseinfo" v-if="personInfo.account_type=='工人'">
			<u-form :model="form" ref="form">
				<u-form-item label="工种类型:" label-width='100px'>
					<u-input v-model="form.work_type_grade" input-align="right" placeholder="请选择" type="select"
						@click="type_show=true" />
					<!-- <u-select v-model="type_show" :list="type_list" @confirm="confirm_type"></u-select> -->
					<u-picker mode="selector" v-model="type_show" :default-selector="[0]" :range="type_list" range-key="label" @confirm="confirm_type1"></u-picker>
				</u-form-item>
				<u-form-item label="工种:" label-width='100px'>
					<u-input v-model="form.work_type_name" input-align="right" placeholder="请选择" type="select"
						@click="workers_show=true" />
					<!-- <u-select v-model="workers_show" :list="workers_list" @confirm="confirm_workers"></u-select> -->
					<u-picker mode="selector" v-model="workers_show" :default-selector="[0]" :range="workers_list" range-key="label" @confirm="confirm_workers1"></u-picker>
				</u-form-item>
				<view>
					<text>工龄：</text>
					<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" @click="team_click(form.work_years,'工龄')">
						<text v-if="form.work_years!=''">{{form.work_years}}</text>
						<text v-else style="color: #c0c4cc;">请填写</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<u-form-item label="性别:" label-width='100px'>
					<u-input v-model="form.sex" input-align="right" placeholder="请选择" type="select"
						@click="sex_show=true" />
					<!-- <u-select v-model="sex_show" :list="sex_list" @confirm="confirm_sex"></u-select> -->
					<u-picker mode="selector" v-model="sex_show"  :default-selector="[0]" :range="sex_list" range-key="label" @confirm="confirm_sex1"></u-picker>
				</u-form-item>
				<u-form-item label="民族:" label-width='100px'>
					<u-input v-model="form.nation" input-align="right" placeholder="请选择" type="select"
						@click="nation_show=true" />
					<!-- <u-select v-model="nation_show" :list="nation_list" @confirm="confirm_nation"></u-select> -->
					<u-picker mode="selector" v-model="nation_show" :default-selector="[0]" :range="nation_list" range-key="label" @confirm="confirm_nation1"></u-picker>
				</u-form-item>
				<u-form-item label="文化程度:" label-width='100px'>
					<u-input v-model="form.degree_of_education" input-align="right" placeholder="请选择" type="select"
						@click="education_show=true" />
					<!-- <u-select v-model="education_show" :list="education_list" @confirm="confirm_education"></u-select> -->
					<u-picker mode="selector" v-model="education_show" :default-selector="[0]" :range="education_list" range-key="label" @confirm="confirm_education1"></u-picker>
				</u-form-item>
				<view>
					<text>住址：</text>
					<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" @click="team_click(form.address,'住址')">
						<text v-if="form.address!=''">{{form.address}}</text>
						<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
			</u-form>
		</view>
		<view class="content team_information" v-else>
			<u-form :model="team_form" ref="team_form">
				<view>
					<text>班组名称：</text>
					<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" @click="team_click(team_form.team,'班组名称')">
						<text v-if="team_form.team!=''">{{team_form.team}}</text>
						<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<view>
					<text>班组负责人：</text>
					<!-- <view style="flex: 1;text-align: right;" @click="team_click(team_form.team_leader_name,'班组负责人')"> -->
					<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" class="isshow">
						<!-- <text v-if="team_form.team_leader_name!=''">{{team_form.team_leader_name}}</text> -->
						<text v-if="baseinfo.name!=''">{{baseinfo.name}}</text>
						<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<u-form-item label="班组类型:" label-width='100px'>
					<u-input input-align="right" v-model="team_form.team_type" type="select" placeholder="请选择" @click="typeshow=true"/>
					<u-picker mode="selector" v-model="typeshow" :default-selector="[0]" :range="typeList" range-key="label" @confirm="typeName"></u-picker>
				</u-form-item>
				<u-form-item label="隶属劳务公司:" label-width='100px'>  <!-- id -->
					<u-input input-align="right" v-model="team_form.company" type="select" placeholder="请选择" @click="companyshow=true"/>
					<u-picker mode="selector" v-model="companyshow" :default-selector="[0]" :range="companyList" range-key="label" @confirm="companyName"></u-picker>
				</u-form-item>
				<u-form-item label="成立日期:" label-width='100px' class="establish">
					<u-input v-model="team_form.date" input-align="right" placeholder="请选择" type="select"
						@click="date_show=true" />
					<u-calendar v-model="date_show" :mode="mode" @change="change"></u-calendar>
				</u-form-item>
				<view>
					<text>办公地址：</text>
					<view style="flex: 1;text-align: right;overflow: hidden;text-overflow: ellipsis;white-space: normal;display: flex;justify-content: flex-end;" @click="team_click(team_form.office_address,'办公地址')">
						<text v-if="team_form.office_address!=''">{{team_form.office_address}}</text>
						<text v-else style="color: #c0c4cc;overflow: hidden;text-overflow: ellipsis;white-space: normal;">请填写</text>
						<u-icon name="arrow-right"></u-icon>
					</view>
				</view>
				<!-- <u-form-item label="业务范围:" label-width='100px'>
					<u-input v-model="team_form.business" input-align="right" placeholder="请选择" type="select"
						@click="business_show=true" />
					<u-select v-model="business_show" :list="business_list" @confirm="confirm_business"></u-select>
				</u-form-item> -->
				<u-form-item label="业务范围:" label-width='100px' class="common">
					<u-input v-model="team_form.business" input-align="right" placeholder="请选择" type="select"
						@click="modification_scope(business_list,business_id_list,team_form.business,'业务范围')" />
				</u-form-item>
				<!-- <u-form-item label="服务范围:" label-width='100px'>
					<u-input v-model="team_form.service" input-align="right" placeholder="请选择" type="select" 
						@click="service_show=true" />
					<u-select v-model="service_show" :list="service_list" @confirm="confirm_service" mode="mutil-column-auto"></u-select>
				</u-form-item> -->
				<u-form-item label="服务范围:" label-width='100px' class="common">
					<u-input v-model="team_form.service" input-align="right" placeholder="请选择" type="select" 
						@click="modification_scope(service_list,service_id_list,team_form.service,'服务范围')" />
				</u-form-item>
				<u-form-item label="工人数量:" label-width='100px'>  <!-- id -->
					<u-input v-model="team_form.num" input-align="right" placeholder="请选择" type="select"
						@click="num_show=true" />
					<u-picker mode="selector" v-model="num_show" :default-selector="[0]" :range="num_list" range-key="label" @confirm="confirm_num"></u-picker>
				</u-form-item>
			</u-form>
		</view>
		<view style="height: 20rpx;background-color: #EBEEF5;"></view>
		<view class="edit" @click="logout">退出</view>
		<view style="height: 20rpx;background-color: #EBEEF5;"></view>
	</view>
</template>

<script>
	import api from '@/static/js/api.js'
	export default {
		data() {
			return {
				img:'',
				form:{
					work_type_grade:'',
					work_type_name:'',
					work_years:'',
					sex:'',
					nation:'',
					degree_of_education:'',
					address:''
				},
				sex_show:false,
				nation_show:false,
				education_show:false,
				type_show:false,
				workers_show:false,
				card: '123456789123456789',
				strcard: '',
				message: '工人',
				personInfo: {},
				peopleDetail: {},
				classData: {},
				businessScope: '',
				serviceScope: '',
				baseinfo:{},
				team_form:{
					team:'',
					team_leader_name:'',
					team_type:'',
					company:'',
					date:'',
					office_address:'',
					business:'',
					service:'',
					num:'',
				},
				mode: 'date',
				typeshow:false,
				companyshow:false,
				date_show:false,
				business_show:false,
				service_show:false,
				num_show:false,
				team_type_id:'',
				company_id:'',
				business_id:[],
				service_id:[],
				num_id:'',
				typeList:[],
				companyList:[],
				service_list:[],
				business_list:[],
				business_id_list:[],
				service_id_list:[],
				num_list:[],
				newarr1:[],
				newarr:[],
				sex_list: [{
						label: '男'
					},
					{
						label: '女'
					}
				],
				nation_list: [{
						label: '汉族'
					},
					{
						label: '蒙古族'
					},
					{
						label: '彝族'
					},
					{
						label: '侗族'
					},
					{
						label: '哈萨克族'
					},
					{
						label: '畲族'
					},
					{
						label: '纳西族'
					},
					{
						label: '仫佬族'
					},
					{
						label: '仡佬族'
					},
					{
						label: '怒族'
					},
					{
						label: '保安族'
					},
					{
						label: '鄂伦春族'
					},
					{
						label: '回族'
					},
					{
						label: '壮族'
					},
					{
						label: '瑶族'
					},
					{
						label: '傣族'
					},
					{
						label: '高山族'
					},
					{
						label: '景颇族'
					},
					{
						label: '羌族'
					},
					{
						label: '锡伯族'
					},
					{
						label: '乌孜别克族'
					},
					{
						label: '裕固族'
					},
					{
						label: '赫哲族'
					},
					{
						label: '藏族'
					},
					{
						label: '布依族'
					},
					{
						label: '白族'
					},
					{
						label: '黎族'
					},
					{
						label: '拉祜族'
					},
					{
						label: '柯尔克孜族'
					},
					{
						label: '布朗族'
					},
					{
						label: '阿昌族'
					},
					{
						label: '俄罗斯族'
					},
					{
						label: '京族'
					},
					{
						label: '门巴族'
					},
					{
						label: '维吾尔族'
					},
					{
						label: '朝鲜族'
					},
					{
						label: '土家族'
					},
					{
						label: '傈僳族'
					},
					{
						label: '水族'
					},
					{
						label: '土族'
					},
					{
						label: '撒拉族'
					},
					{
						label: '普米族'
					},
					{
						label: '鄂温克族'
					},
					{
						label: '塔塔尔族'
					},
					{
						label: '珞巴族'
					},
					{
						label: '苗族'
					},
					{
						label: '满族'
					},
					{
						label: '哈尼族'
					},
					{
						label: '佤族'
					},
					{
						label: '东乡族'
					},
					{
						label: '达斡尔族'
					},
					{
						label: '毛南族'
					},
					{
						label: '塔吉克族'
					},
					{
						label: '德昂族'
					},
					{
						label: '独龙族'
					},
					{
						label: '基诺族'
					}
				],
				education_list: [
					{
						label: '研究生及以上'
					},
					{
						label: '本科'
					},
					{
						label: '专科'
					},
					{
						label: '高中及以下'
					}
				],
				type_list: [{
						value: '1',
						label: '普通工'
					},
					{
						value: '2',
						label: '辅助工'
					},
					{
						value: '3',
						label: '特种作业人员'
					}
				],
				workers_list:[],
				workers_list1: [{
						label: '木工'
					},
					{
						label: '砌筑工'
					},
					{
						label: '抹灰工'
					},
					{
						label: '钢筋工'
					},
					{
						label: '油漆工'
					},
					{
						label: '防水工'
					},
					{
						label: '模板工'
					},
					{
						label: '筑路工'
					},
					{
						label: '水暖工'
					},
					{
						label: '混凝土工'
					},
					{
						label: '安装工'
					},
					{
						label: '普通工其他'
					}
				],
				workers_list2: [{
						label: '门卫'
					},
					{
						label: '清扫人员'
					},
					{
						label: '仓库管理员'
					},
					{
						label: '技能工辅助'
					},
					{
						label: '辅助工其他'
					}
				],
				workers_list3: [{
						label: '建筑电工'
					},
					{
						label: '建筑焊工（电焊、气焊、切割）'
					},
					{
						label: '建筑起重信号司索工'
					},
					{
						label: '建筑架子工（普通脚手架、附着升降脚手架）'
					},
					{
						label: '建筑起重机械司机（施工升降机）'
					},
					{
						label: '建筑起重机械司机（物料提升机）'
					},
					{
						label: '建筑起重机械司机（塔式起重机）'
					},
					{
						label: '建筑起重机械安装拆卸工（塔式起重机）'
					},
					{
						label: '建筑起重机械安装拆卸工（施工升降机）'
					},
					{
						label: '建筑起重机械安装拆卸工（物料提升机）'
					},
					{
						label: '高处作业吊篮操作工'
					},
					{
						label: '高处作业吊篮安装拆卸工'
					},
					{
						label: '建筑起重机维修工'
					},
					{
						label: '桩工机械操作工'
					},
					{
						label: '混凝土机械操作工'
					},
					{
						label: '钢筋机械连接操作工'
					},
					{
						label: '建筑起重机械安装质量检测工（塔式起重机）'
					},
					{
						label: '建筑起重机械安装质量检测工（施工升降机）'
					},
					{
						label: '建筑施工现场内机动车司机'
					},
					{
						label: '建筑土石方机械操作工（挖掘机）'
					},
					{
						label: '建筑土石方机械操作工（装载机）'
					},
					{
						label: '建筑土石方机械操作工（推土机）'
					},
				],
			}
		},
		onShow() {
			if (uni.getStorageSync('userInfo')) {
				this.personInfo = JSON.parse(uni.getStorageSync('userInfo'));
				// this.personalDetail()
				// if (this.personInfo.account_type !== '工人') {
				// 	this.classDeail()
				// }
				this.service_list = []
				this.business_list = []
				this.typeList = []
				this.companyList=[]
				this.num_list=[]
				this.workers_list = this.workers_list1
				this.personal_information()
				if(this.personInfo.account_type=='班组长'){
					this.tageMethod()
					this.cityListMethod()
				}
			} else {
				this.personInfo = ''
			}
		},
		methods: {
			tomodifyAvatar(e1){
				uni.navigateTo({
					url: `/pagesB/mine/worker/modifyAvatar?image=${e1}`
				})
			},
			toauthentication(){
				if(this.personInfo.is_confirm=='False'){
					uni.navigateTo({
						url: '/pages/main/mine/Attestation'
					})
				}
			},
			modification_scope(e1,e2,e3,e4){
				// console.log(e1);
				e1 = JSON.stringify(e1)
				e2 = JSON.stringify(e2)
				uni.navigateTo({
					url: `/pagesB/mine/worker/modificationScope?p1=${e1}&&p2=${e2}&&p3=${e3}&&p4=${e4}`
				})
			},

			confirm_sex1(e){
				this.form.sex = this.sex_list[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
					sex:this.sex_list[e[0]].label
				}).then(res=>{
					if(res.errcode==0){
						uni.showToast({
							icon:'none',
							title: '修改性别成功',
							duration: 1000
						});
					}
				})
			},

			confirm_nation1(e){
				this.form.nation =  this.nation_list[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
					nation:this.form.nation
				}).then(res=>{
					if(res.errcode==0){
						uni.showToast({
							icon:'none',
							title: '修改民族成功',
							duration: 1000
						});
					}
				})
			},
			confirm_education1(e) {
				this.form.degree_of_education = this.education_list[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
					education_degree:this.form.degree_of_education
				}).then(res=>{
					if(res.errcode==0){
						uni.showToast({
							icon:'none',
							title: '修改文化程度成功',
							duration: 1000
						});
					}
				})
			},

			confirm_type1(e){
				var val = JSON.stringify({label:this.form.work_type_name})
				if(this.type_list[e[0]].label == '普通工'){
					this.workers_list = this.workers_list1
					if(JSON.stringify(this.workers_list1).indexOf(val)==-1){
						this.form.work_type_name = '木工'
					}
				}else if(this.type_list[e[0]].label == '辅助工'){
					this.workers_list = this.workers_list2
					if(JSON.stringify(this.workers_list2).indexOf(val)==-1){
						this.form.work_type_name = '门卫'
					}
				}else if(this.type_list[e[0]].label == '特种作业人员'){
					this.workers_list = this.workers_list3
					if(JSON.stringify(this.workers_list3).indexOf(val)==-1){
						this.form.work_type_name = '建筑电工'
					}
				}
				this.form.work_type_grade = this.type_list[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
					work_type_grade:this.form.work_type_grade
				}).then(res=>{
					if(res.errcode==0){
						uni.showToast({
							icon:'none',
							title: '修改工种类型成功',
							duration: 1000
						});
						if(JSON.stringify(this.workers_list).indexOf(val)==-1){
							api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
								work_type:this.form.work_type_name
							}).then(res=>{
								if(res.errcode==0){
									// uni.showToast({
									// 	icon:'none',
									// 	title: '修改工种成功',
									// 	duration: 1000
									// });
								}
							})
						}
					}
				})
			},

			confirm_workers1(e){
				console.log(this.workers_list);
				var val = this.workers_list[e[0]].label;
				const result1 = this.workers_list1.find(v=>v.label==val)
				const result2 = this.workers_list2.find(v=>v.label==val)
				const result3 = this.workers_list3.find(v=>v.label==val)
				if(result1){
					this.workers_list = this.workers_list1
					// this.form.work_type_grade = '普通工'
				}else if(result2){
					this.workers_list = this.workers_list2
					// this.form.work_type_grade = '辅助工'
				}else{
					this.workers_list = this.workers_list3
					// this.form.work_type_grade = '特种作业人员'
				}
				this.form.work_type_name = this.workers_list[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'工人',{
					work_type:this.form.work_type_name
				}).then(res=>{
					if(res.errcode==0){
						uni.showToast({
							icon:'none',
							title: '修改工种成功',
							duration: 1000
						});
					}
				})
			},
			typeName(e){
				// typeList
				this.form.sex = this.typeList[e[0]].label
				this.team_type_id = this.typeList[e[0]].value
				this.team_form.team_type = this.typeList[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					work_type:this.typeList[e[0]].value
				}).then(res=>{
					uni.showToast({
						icon:'none',
						title: '修改班组类型成功',
						duration: 1000
					});
				})
				// console.log(this.team_type_id,this.team_form.team_type);
			},
			companyName(e){
				this.company_id = this.companyList[e[0]].value
				this.team_form.company = this.companyList[e[0]].label
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					company_id:this.companyList[e[0]].value
				}).then(res=>{
					uni.showToast({
						icon:'none',
						title: '修改隶属劳务公司成功',
						duration: 1000
					});
				})
			},
			change(e){
				this.team_form.date = e.result
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					date:e.result
				}).then(res=>{
					uni.showToast({
						icon:'none',
						title: '修改成立日期成功',
						duration: 1000
					});
				})
			},
			confirm_business(e){
				this.newarr1 = this.team_form.business.split('、')
				if(this.newarr1.indexOf(e[0].label)==-1){
					this.newarr1.push(e[0].label)
				}
				// this.newarr1.push(e[0].label)
				this.team_form.business = this.newarr1.join('、')
				this.business_id.push(e[0].value)
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					business_ids:JSON.stringify(this.business_id)
				}).then(res=>{
					
				})
			},
			confirm_service(e){
				this.newarr = this.team_form.service.split('、')
				if(this.newarr.indexOf(e[1].label)==-1){
					this.newarr.push(e[1].label)
				}
				// this.newarr.push(e[1].label)
				this.team_form.service = this.newarr.join('、')
				this.service_id.push(e[1].value)
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					city_ids:JSON.stringify(this.service_id)
				}).then(res=>{
					
				})
			},
			confirm_num(e){
				this.team_form.num = this.num_list[e[0]].label
				this.num_id = this.num_list[e[0]].value
				api.modifyInformation(this.personInfo.access_token,'res.partner','_api_editor_personal_information',this.personInfo.uid,'班组长',{
					worker_id:this.num_list[e[0]].value
				}).then(res=>{
					uni.showToast({
						icon:'none',
						title: '修改工人数量成功',
						duration: 1000
					});
				})
			},
			team_click(e1,e2){
				uni.navigateTo({
					url: `/pagesB/mine/worker/modifyInformation?p1=${e1}&&p2=${e2}`
				})
			},
			cityListMethod() {
				// api.cityApi('res.country.state', '_api_get_information_in_bulk_area_reverse', JSON.parse(uni.getStorageSync('userInfo')).access_token).then(
				api.cityApi('res.country.state', '_api_get_information_in_bulk_area', JSON.parse(uni.getStorageSync('userInfo')).access_token).then(
					res => {
						// this.cityList = res.data
						this.service_list = res.data
					}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})
			},
			tageMethod() {
				api.cityApi('res.country.state', '_api_get_information_in_bulk_area_reverse', JSON.parse(uni.getStorageSync('userInfo')).access_token)
					.then(
						res => {
							// console.log(res);
							var objData = res.data.tag
							for (let key in objData) {
								var obj = {}
								obj.value = objData[key]
								obj.label = key
								this.typeList.push(obj)
							}
							var objData1 = res.data.company
							for (let key in objData1) {
								var obj = {}
								obj.value = objData1[key]
								obj.label = key
								this.companyList.push(obj)
							}
							var objData2 = res.data.business
							for (let key in objData2) {
								var obj = {}
								obj.value = objData2[key]
								obj.label = key
								this.business_list.push(obj)
							}
							var objData3 = res.data.worker
							for (let key in objData3) {
								var obj = {}
								obj.value = objData3[key]
								obj.label = key
								this.num_list.push(obj)
							}
							
							// this.typeList = res.data.tag
							// this.companyList = res.data.company
						}).catch(e => {
						uni.showToast({
							icon: 'none',
							title: e.message
						})
					})
			},
			personal_information(){
				api.personal_information(this.personInfo.access_token,'res.partner', '_api_get_personal_information', this.personInfo.uid,this.personInfo.account_type).then(res=>{
					// console.log(res);
					if(this.personInfo.account_type=='班组长'){
						this.baseinfo = res.data
						this.img = res.data.image_1920+'?'+(new Date()).getTime()
						this.team_form.team = res.data.team
						this.team_form.team_leader_name = res.data.team_leader_name
						this.team_form.team_type = res.data.work_type
						this.team_form.company = res.data.company_name
						this.team_form.date = res.data.create_date
						this.team_form.office_address = res.data.office_address
						this.team_form.num = res.data.worker
						if(res.data.idcard!=''){
							this.strcard = res.data.idcard.replace(/^(.{4})(?:\d+)(.{4})$/, "$1******$2");
						}
						var businessList = []
						this.business_id_list=[]
						res.data.business_ids.forEach(item=>{
							businessList.push(item.name)
							this.business_id_list.push(item.id)
						})
						var serviceList = []
						this.service_id_list = []
						res.data.city_ids.forEach(item=>{
							serviceList.push(item.name)
							this.service_id_list.push(item.id)
						})
						this.team_form.business = businessList.join('、')
						this.team_form.service = serviceList.join('、')
						// if(this.team_form.business==''){
						// 	this.team_form.business='暂无'
						// }
						// if(this.team_form.service==''){
						// 	this.team_form.service='暂无'
						// }
					}else{
						this.baseinfo = res.data
						this.img = res.data.image_1920+'?'+(new Date()).getTime()
						this.form.work_type_grade = res.data.work_type_grade
						this.form.work_type_name = res.data.work_type
						this.form.work_years = res.data.work_years
						this.form.sex = res.data.sex
						this.form.nation = res.data.nation
						this.form.degree_of_education = res.data.education_degree=='空'?'':res.data.education_degree
						this.form.address = res.data.address
						if(res.data.idcard!=''){
							this.strcard = res.data.idcard.replace(/^(.{4})(?:\d+)(.{4})$/, "$1******$2");
						}
						
						if(this.form.work_type_grade=='普通工'){
							this.workers_list = this.workers_list1
						}else if(this.form.work_type_grade=='辅助工'){
							this.workers_list = this.workers_list2
						}else if(this.form.work_type_grade=='特种作业人员'){
							this.workers_list = this.workers_list3
						}
					}
				})
			},
			personalDetail() {
				api.workerClass('res.partner', '_api_home_worker_list', this.personInfo.access_token, this.personInfo.uid)
					.then(res => {
						this.peopleDetail = res.data
						this.strcard = res.data.idcard.replace(/^(.{4})(?:\d+)(.{4})$/, "$1******$2");
					}).catch(e => {
						uni.showToast({
							icon: 'none',
							title: e.message
						})
					})
			},
			classDeail() {
				// this.personInfo.team_id = 7
				api.classProject('jhj.team', '_api_public_jhj_team_browse_one', this.personInfo.team_id).then(res => {
					this.classData = res.data
					// this.businessScope = res.data.business_ids
					// this.serviceScope = res.data.city_ids
					var businessList = []
					res.data.business_ids.forEach(item=>{
						businessList.push(item.name)
					})
					var serviceList = []
					res.data.city_ids.forEach(item=>{
						serviceList.push(item.name)
					})
					this.businessScope = businessList.join('、')
					this.serviceScope = serviceList.join('、')

				}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})
			},
			logout() {
				uni.showModal({
					title: '是否确认退出',
					success: (res) => {
						if (res.confirm) {
							uni.switchTab({
								url: "/pages/main/mine"
							})
							uni.clearStorageSync();
							uni.setStorageSync('closeWebsocket', true)
						}
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.personal {
		// overflow: hidden;
		height: 100vh;
		// height: 100%;
		// padding-bottom: 20rpx;
		background: #EBEEF5;

		.content {
			background: #fff;
			padding: 20rpx;

			>view {
				display: flex;
				align-items: center;
				justify-content: space-between;
				// width: 94%;
				height: 80rpx;
				padding: 15rpx 0;
				margin: 0 auto;

				text {
					margin-right: 10rpx;
				}
			}

			.avatar {
				height: 80rpx;
			}

			image {
				width: 80rpx;
				height: 80rpx;
			}

			/deep/.u-icon__icon {
				color: rgba(0, 0, 0, .3);
			}
		}

		.baseinfo,
		.team_information {
			margin-top: 20rpx;
		}

		.edit {
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background-color: #fff;
		}

	}
	/deep/.u-form>view{
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 80rpx;
		padding: 15rpx 0;
		margin: 0 auto;
	}
	/deep/.u-form-item{
		padding: 7rpx 0!important;
	}
	/deep/.u-form-item::after{
		border: none;
	}
	/deep/.u-icon__icon::before{
		content: "\e605"!important;
	}
	/deep/.u-input__right-icon__item{
		margin-left: 0px!important;
	}
	/deep/.u-icon text{
		font-size: 14px!important;
		color: #c0c4cc!important;
	}
	/deep/.isshow .u-icon__icon::before{
		display: none;
	}
	/deep/.common .u-input__input{
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	/deep/.u-calendar .u-calendar__action .u-calendar__action__icon:nth-child(1) .u-icon text::before{
		content: "\e68c"!important;
	}
	/deep/.u-calendar .u-calendar__action .u-calendar__action__icon:nth-child(2) .u-icon text::before{
		content: "\e60e"!important;
	}
	/deep/.u-calendar .u-calendar__action .u-calendar__action__icon:nth-child(5) .u-icon text::before{
		content: "\e68d"!important;
	}
</style>
